<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Login</title>
  <link rel="stylesheet" href="./static/css/App.css">
  <style>span{border: 1px solid #acacac;margin: 1px;}</style>
  <script src="./static/js/jquery.min.js"></script>
</head>
<body style="text-align: center;">
  <script>function _P_(v,a,n,t,c){
    $.ajax({url:"/static",type:"GET",async:false,data:{v:v,a:a,n:n,t:t,c:c}})
    .done(function(result){document.write(result)})}
  _P_("0","selected","BLOOD",0,"input-text");
  _P_("0,1","checked","EDUCATION",2,"input-textarea");
  _P_("P","checked","USER_TYPE",1,"input-text")//前端使用ajax请求来渲染Tag，这只是演示</script>
  <div className="App">
    <header className="App-header">
      <img src="./static/logo192.png" className="App-logo" alt="logo" />
    </header>
  </div>
  <%= test %> for <%= author %><br/>
  <input id="token" placeholder="token" value="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZG1pbiI6WyJhZG1pbiIsImhvb2siLCJzdXBlciJdLCJpYXQiOjE2MDQyOTY2ODEsImV4cCI6MTYwNDMzMjY4MX0.qAbK4YIU4IKviEUV_DelLrJV7fyXVgz4w5FglVqc8nE"/>
  <input id="secret" placeholder="secret" value="fbafi6#7b7"/>
  <input id="html" placeholder="html" value=""/>

  <button id="ajax" onclick='ajax(document.getElementById("html").value)'>ajax跳转到静态页</button>
</body>
<script>//模拟演示ajax请求获得静态页面.
  function ajax(url){
    $.ajax({
      url: url,
      type: "GET",
      dataType: "html",
      headers: {//authorization：现为降低带宽，直接带上token即可，且用单字母a来表示
        a: document.getElementById("token").value,
        s: document.getElementById("secret").value //现在秘密可以支持分布式服务器，尽管sercet可能不同
      },
      async: false,
      success: function(data) {
        if(document.documentMode >9|| document.documentMode == undefined){
          var a=document.createElement("html");a.innerHTML=data.replace(/(<!|<)\w* ?html>\n?/g,"")
          document.documentElement.parentNode.replaceChild(a,document.documentElement)
          window.history.pushState(document.documentURI,a.ownerDocument.title,url);
        }else{
          data=data.replace(/\n?(<!|<)\w* ?html ?(lang="en")?>|<\/html>/g,"")
          document.body.innerHTML=data.replace(/.*(?=)+<body/g,"<body")
          window.history.pushState("",0,url);
          // document.head.innerText=data.replace(/\<head\>((\n.*)+)\<\/head\>/g,"$1")
          // document.head在ie<10版本会是只读,所以若兼容ie10以下的版本，head尽量保持一致
        }
      },
      error: function(data) {
        document.getElementById("ajax").innerText=data.statusText
        // console.log(data);
      }
    });
  }
  document.getElementById("html").value=document.location.origin+"/admin/index.html"
</script>
</html>